import {queryPay} from '../api/order'
import { defineStore } from "pinia"
export const useVideo = defineStore('video', () => {
    const videoInfor = reactive({
        orderState: false,
        videoPrice: null,
        easyPoint: null,
        logicPoint:null,
        contentPoint: null
    })
    //检查是否购买
    const checkPay = async(id: number) => {
        const {token} = $(useUser())
        if(!token) {
            videoInfor.orderState = false;
            return
        } 
        if(await(queryPay(id)) ){
            videoInfor.orderState = true;
        }else {
            videoInfor.orderState = false;
        }
    }
    return {
        ...(toRefs(videoInfor)),
        checkPay
    }
})